package com.cesc.springcloud;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.URI;
import java.util.List;

@RestController
@SpringBootApplication
@EnableFeignClients
public class Application {

    @Autowired
    private ProductService productService;
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }


    @GetMapping("/getProducts")
    public List<Product> getProducts() {
      return productService.getProducts();
    }

    @GetMapping("/saveProduct")
    public Product saveProduct() {
        Product product=new Product();
        product.setId(null);
        product.setProductCode("12345");
        product.setProductName("test12345");
        product.setDescription("123456");
        product.setPrice(1.5F);
        return productService.saveProductToDb(product);
    }

}
